package com.bwie.system.init;

import com.bwie.common.domain.Dict;
import com.bwie.common.domain.Orders;
import com.bwie.system.mapper.InitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
public class InitOrder implements ApplicationRunner {

    @Autowired
    private InitMapper initMapper;
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<Orders> list = initMapper.findOrder();
        redisTemplate.opsForValue().set("order:list",list,30, TimeUnit.MINUTES);

        //数据字典存缓存‘
       List<Dict> dictList =  initMapper.findDict();
        redisTemplate.opsForValue().set("dicts:list",dictList,30,TimeUnit.MINUTES);

    }
}
